﻿using System;
using System.Diagnostics;
using System.IO;

using Keyki.NefClass.Kernel;
using Keyki.NefClass.Kernel.Fuzzy.ChooceRule;
using Keyki.NefClass.Kernel.Fuzzy.FuzzySet;
using Keyki.NefClass.Kernel.Fuzzy.Trainer;
using Keyki.NefClass.Kernel.Reader;

namespace Keyki.NefClass.Demo
{
	class Program
	{
		static void Main(string[] args)
		{
			var reader = new ReaderCSV();
			const String fileName = "IRIS.csv";
			Stopwatch timer = new Stopwatch();

			AbstractRule abstractRule = new BestForClassRule();
			ITrainer abstractTrainer = new TriangleSetTrainer();

			Core.NefClass = new NefClass.Kernel.Network.NefClass(abstractRule, abstractTrainer, 3);
			Core.NefClass.Init(fileName, reader);
			Core.NefClass.IsAny = true;
			Core.NefClass.TraineeSample = 1;
			
			timer.Start();
			Core.NefClass.SetAllLV(3, new TriangleFuzzySet());
			Core.NefClass.CreateRulles();
			Core.NefClass.Train();
			Core.NefClass.Work();

			timer.Stop();

			var stream = new StreamWriter(Console.OpenStandardOutput());
			//var stream = new StreamWriter("rules.txt");
			stream.AutoFlush = true;

			Core.NefClass.GetRullesInStream(stream);
			Console.WriteLine("Time: " + timer.ElapsedMilliseconds);
			Console.ReadKey();
		}//Main
	}//Program
}
